<?php
/**
 * Created by PhpStorm.
 * User: liuxin
 * Date: 2018/1/4
 * Time: 下午5:04
 */
namespace common\components;
use Yii;
use yii\base\ErrorException;

class Authorize
{

    public static  function checkAccess(){
        if(!Helper::userClientServerIpIsAllowed()){
            throw new ErrorException('',Yii::$app->params['ApiCode']['ipIsNotAllowed']);
        }
        if(!Yii::$app->request->post()){

            throw new ErrorException('',Yii::$app->params['ApiCode']['paramsEmpty']);
        }

        if(!Helper::parseCheckSign()){
            throw new ErrorException('',Yii::$app->params['ApiCode']['signError']);
        }
    }
}